package com.pm.service.file.impl;

import com.pm.entity.po.file.FileLib;
import com.pm.mapper.file.FileLibMapper;
import com.pm.service.file.FileService;
import com.pm.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class FileServiceImpl extends BaseServiceImpl<FileLib> implements FileService {
    @Autowired
    FileLibMapper fileLibMapper;

    @Resource
    private void setBaseMapper(FileLibMapper fileLibMapper) {
        super.setBaseMapper(fileLibMapper);
    }

    /**
     * 删除文件
     *
     * @param id
     * @return
     */
    @Override
    public Boolean deleteFileLib(Integer id) {
        if (id == null) {
            // 判断负面清单
            if (fileLibMapper.deleteFileLibA(id) != 0) {
                return false;
            }
            // 判断目标任务进度附件
            if (fileLibMapper.deleteFileLibTsf(id) != 0) {
                return false;
            }
            // 考核评分附件表 subtask_dept_task_file
            if (fileLibMapper.deleteFileLibSdtf(id) != 0) {
                return false;
            }
            // 日常工作台账ledger
            if (fileLibMapper.deleteFileLibLedger(id) != 0) {
                return false;
            }
            // 负面清单
            if (fileLibMapper.deleteFileLibNc(id) != 0) {
                return false;
            }
        }
        // 删除
        return fileLibMapper.deleteFileLib(id);

    }
}
